import { BasicColumn, FormSchema } from '@/components/Table';
import { dateUtil } from '@/utils/dateUtil';

export const billColumns: BasicColumn[] = [
  {
    title: '发票编号',
    dataIndex: 'billNo',
    width: 50,
  },
  {
    title: '开票类型',
    dataIndex: 'bileType',
    width: 50,
    customRender: ({ text }) => {
      if (text == '0') {
        return '个人';
      } else if (text == '1') {
        return '企业';
      }
    },
  },
  {
    title: '发票金额',
    dataIndex: 'amount',
    width: 50,
  },
  {
    title: '申请时间',
    dataIndex: 'createDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  {
    title: '发票抬头',
    dataIndex: 'companyName',
    width: 50,
  },
  {
    title: '发票邮箱',
    dataIndex: 'email',
    width: 50,
  },
  {
    title: '发票性质 ',
    dataIndex: 'sort',
    width: 50,
    customRender: ({ text }) => {
      return '纸质';
    },
  },
  {
    title: '开票状态',
    dataIndex: 'status',
    width: 50,
    customRender: ({ text }) => {
      if (text == '0') {
        return '待开';
      } else if (text == '1') {
        return '已开';
      } else if (text == '2') {
        return '已领取';
      } else if (text == '3') {
        return '已驳回';
      }
    },
  },
  {
    title: '备注 ',
    dataIndex: 'memo',
    width: 50,
  },
];
export const orderColumns: BasicColumn[] = [
  {
    title: '订单编号',
    dataIndex: 'sn',
    width: 50,
  },
  {
    title: '姓名',
    dataIndex: 'memberName',
    width: 50,
  },
  {
    title: '充电站',
    dataIndex: 'stationName',
    width: 50,
  },
  {
    title: '充电终端',
    dataIndex: 'pileName',
    width: 50,
  },
  {
    title: '开始时间',
    dataIndex: 'startDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  {
    title: '结束时间',
    dataIndex: 'endDate',
    width: 160,
    customRender: ({ text }) => {
      return dateUtil(text).format('YYYY-MM-DD HH:mm:ss');
    },
  },
  {
    title: '充电时长(时)',
    dataIndex: 'power',
    width: 50,
  },
  {
    title: '充电总量(度)',
    dataIndex: 'power',
    width: 50,
    customRender: ({ record }) => {
      return (record.endDate.time - record.startDate.time) / 1000 / 60;
    },
  },
  {
    title: '电费(元)',
    dataIndex: 'powerMoney',
    width: 50,
  },
  {
    title: '服务费(元)',
    dataIndex: 'serviceMoney',
    width: 50,
  },
  {
    title: '停车费(元)',
    dataIndex: 'parkMoney',
    width: 50,
  },
  {
    title: '超时占桩费(元)',
    dataIndex: 'pileTimeoutSumFee',
    width: 50,
  },
  {
    title: '总金额(元)',
    dataIndex: 'spendMoney',
    width: 50,
  },
];
export const billSearchFormSchema: FormSchema[] = [
  {
    field: 'companyId',
    label: '企业',
    component: 'ApiSelect',
    componentProps: {
      api: '/admin/company/listAll',
      treeDefaultExpandAll: false,
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
    },
    required: false,
  },
  {
    field: 'status',
    label: '开票状态',
    component: 'Select',
    componentProps: {
      options: [
        { name: '待开', id: '0' },
        { name: '已开', id: '1' },
        { name: '已领取', id: '2' },
        { name: '已驳回', id: '3' },
      ],
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
    },
    required: false,
  },
  {
    field: 'bileType',
    label: '开票类型',
    component: 'Select',
    componentProps: {
      options: [
        { name: '个人', id: '0' },
        { name: '企业', id: '1' },
      ],
      fieldNames: {
        label: 'name',
        key: 'id',
        value: 'id',
      },
    },
    required: false,
  },
  {
    field: 'keyword',
    label: '发票编号',
    component: 'Input',
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
  },
];
export const billFormSchema: FormSchema[] = [
  // {
  //   field: 'groupsId',
  //   label: '分组',
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: '/admin/groups/list',
  //     treeDefaultExpandAll: false,
  //     fieldNames: {
  //       label: 'name',
  //       key: 'id',
  //       value: 'id',
  //     },
  //   },
  //   colProps: {
  //     span: 5,
  //   },
  // },
  {
    field: 'name',
    label: '优惠券名称',
    component: 'Input',
  },
  {
    field: 'amount',
    label: '优惠券金额',
    component: 'InputNumber',
    componentProps: {
      precision: 2,
      min: 0,
      max: 100000000,
    },
    required: true,
  },
  {
    field: 'startTime',
    label: '开始时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    required: true,
  },
  {
    field: 'endTime',
    label: '结束时间',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      style: { width: '100%' },
    },
    required: true,
  },
  {
    field: 'byFull',
    label: '满多少可以使用优惠',
    component: 'InputNumber',
    componentProps: {
      precision: 2,
      min: 0,
      max: 100000000,
    },
    required: true,
  },
  {
    field: 'expression',
    label: '优惠券表达式',
    helpMessage: 'price代表订单金额,service代表服务费,例如price*0.8-service',
    component: 'Input',
  },
  {
    field: 'permissions',
    label: '可使用场站',
    component: 'CheckboxGroup',
    componentProps: {
      // options: [
      //   { label: '充电管理', value: '1' },
      //   { label: '车辆管理', value: '2' },
      //   { label: '订单管理', value: '3' },
      //   { label: '发票管理', value: '4' },
      //   { label: '系统管理', value: '6' },
      // ],
    },
  },
];
